package com.elitel.frame.web.cfgqueryfield.controller;

import com.elitel.frame.web.cfgqueryfield.entity.CfgQueryField;
import com.elitel.frame.web.cfgqueryfield.service.CfgQueryFieldService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 单表查询-请求参数列(BaseQueryfield)表控制层
 *
 * @author makejava
 * @since 2025-05-19 15:48:38
 */
@RestController
@RequestMapping("cfgQueryFiled")
public class CfgQueryFieldController {
    /**
     * 服务对象
     */
    @Resource
    private CfgQueryFieldService cfgQueryFieldService;


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<CfgQueryField> queryById(@PathVariable("id") String id) {
        return ResponseEntity.ok(this.cfgQueryFieldService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param cfgQueryField 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<CfgQueryField> add(CfgQueryField cfgQueryField) {
        return ResponseEntity.ok(this.cfgQueryFieldService.insert(cfgQueryField));
    }

    /**
     * 编辑数据
     *
     * @param cfgQueryField 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<CfgQueryField> edit(CfgQueryField cfgQueryField) {
        return ResponseEntity.ok(this.cfgQueryFieldService.update(cfgQueryField));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(String id) {
        return ResponseEntity.ok(this.cfgQueryFieldService.deleteById(id));
    }

}

